package day_2022_9_to_12.Day;

/**
 * @author haomin
 * @date 2022/10/03 10:35
 **/
public class Day32_1_Num1784_CheckOnesSegment {
    class Solution {
        public boolean checkOnesSegment(String s) {
            String[] arr = s.split("0");
            int ans = 0;
            for(String str : arr){
                if(str != "" && str != "0") ans++;
            }
            return ans > 1 ;
        }
    }
    class Solution2 {
        public boolean checkOnesSegment(String s) {
            int l = 0, r = s.length()-1;
            while(l < s.length() && s.charAt(l) == '1') l++;
            while(r >= 0 && s.charAt(r) == '0') r--;
            return (l-1) == r;
        }
    }
}